package health.lm.com.mine.adapter;

import android.support.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

import health.lm.com.component_base.helper.ImageLoaderHelper;
import health.lm.com.mine.R;
import health.lm.com.mine.entity.IntegralRankingListEntity;

/**
 *  积分排行榜
 * @author GQI
 */
public class IntervalRankingListAdapter extends BaseQuickAdapter<IntegralRankingListEntity.Rank_list,BaseViewHolder> {

    public IntervalRankingListAdapter(@Nullable List<IntegralRankingListEntity.Rank_list> data) {
        super(R.layout.item_jf_ranking_list, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, IntegralRankingListEntity.Rank_list item) {
        helper.setText(R.id.tv_name,item.getTitle())
                .setText(R.id.tv_point,String.format("%s分",item.getCredit()));
        ImageLoaderHelper.getInstance().load(mContext,item.getAvatar(),helper.getView(R.id.iv_logo));
        helper.setGone(R.id.iv_pos,false);
        helper.setGone(R.id.tv_pos,false);
        if(helper.getLayoutPosition() == 1){
            helper.setGone(R.id.iv_pos,true);
            helper.setImageResource(R.id.iv_pos,R.drawable.jifen_icon_reward_01);
        }else  if(helper.getLayoutPosition() == 2){
            helper.setGone(R.id.iv_pos,true);
            helper.setImageResource(R.id.iv_pos,R.drawable.jifen_icon_reward_02);
        }else  if(helper.getLayoutPosition() == 3){
            helper.setGone(R.id.iv_pos,true);
            helper.setImageResource(R.id.iv_pos,R.drawable.jifen_icon_reward_03);
        }else {
            helper.setGone(R.id.tv_pos,true);
            helper.setText(R.id.tv_pos,helper.getLayoutPosition()+"");
        }


    }
}
